from selenium import webdriver
from selenium.webdriver.chrome.service import Service  # 使用路径的对象
from selenium.webdriver.common.by import By  # 导入定位的方法

service = Service('f:\\chrom\\chromedriver.exe')
driver = webdriver.Chrome(service=service)

driver.get('https://tieba.baidu.com/')  # 通过id 获取输入框


# ariam = driver.find_element(By.ID, 'iframeu6739266_1')  # 获取到嵌套的页面
# driver.switch_to.frame(ariam)  # 跳转到新的页面


# text_obj = driver.find_element(By.ID, 'title0')
# text_obj.click()  # send_keys 输入数据

# Message: no such element: Unable to locate element:
# {"method":"css selector","selector":"[id="iframeu6739266_1"]"}

# 查看数据是否存在iframe标签里

# import time  # 滑动条下拉
# s = 200
# n = 1000
# for i in range(s, n, 5):  # 实现网页下拉
#      js = 'window.scrollTo(0,%s)' % (i * 100)
#      driver.execute_script(js)
#      time.sleep(0.3)
